package com.wonderful.eyepetizer.ui.pages.detail.viewmodel

import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.wonderful.eyepetizer.app.base.BaseViewModel
import com.wonderful.eyepetizer.data.entity.bean.TopicDetail
import com.wonderful.eyepetizer.data.repo.MainRepo
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

/**
 * Desc:
 * @Author: wonderful
 * @Time: 2024/2/22 16:56
 */
@HiltViewModel
class TopicDetailViewModel @Inject constructor(private val mRepo: MainRepo) : BaseViewModel() {
    var topicDetail = mutableStateOf(TopicDetail())
    var refreshing = mutableStateOf(false)

    fun getTopicDetail(topicId: Int) {
        viewModelScope.launch {
            refreshing.value = true
            mRepo.getTopicDetail(topicId).data?.let {
                topicDetail.value = it
            }
            refreshing.value = false
        }
    }
}